" Basic settings {{{
let mapleader = "'"
set autochdir
set number
set autowrite
set autowriteall
" 使用字符编码次序
set fileencodings=ucs-bom,utf-8,gb18030,latin1
set undodir=~/.config/nvim/undo
if !isdirectory(&undodir)
    call mkdir(&undodir, 'p', 0700)
endif
" }}}
" tab settings {{{
set expandtab "制表符展开成空格
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set smartindent
" }}}
" Mappings {{{
inoremap <c-u> <esc>viwUea
" edit my vimrc file
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" source my vimrc file
nnoremap <leader>xv :source $MYVIMRC<cr>
" }}}
" Abbreviations {{{
iabbrev @@ luyanfei78@163.com
iabbrev ccopy Copyright 2023 Yanfei Lv, all rights reserved.
" }}}
" javascript file settings {{{
augroup filetype_javascript
	autocmd!
	autocmd FileType javascript nnoremap <buffer> <localleader>c I//<esc>
augroup END
" }}}
" python file settings {{{
augroup filetype_python
	autocmd FileType python nnoremap <buffer> <localleader>c I#<esc>
augroup END
" }}}
" Vimscript file settings {{{
augroup filetype_vim
	autocmd!
	autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" QuickfixToggle {{{
nnoremap <leader>q :call QuickfixToggle()<cr>
let g:quickfix_is_open = 0

function! QuickfixToggle()
	if g:quickfix_is_open
		cclose
		let g:quickfix_is_open = 0
		execute g:quickfix_return_to_window . "wincmd w"
	else
		let g:quickfix_return_to_window = winnr()
		copen
		let g:quickfix_is_open = 1
	endif
endfunction
" }}}
" yaml file settings {{{
autocmd BufNewFile,BufRead *.yml set filetype=yaml
" }}}

